let mask = null; // 底层透明底 
let content_body = null; // 弹窗背景 
let btn_confirm = null; 
let btn_close = null;

/*
 *  obj 参数对象
 *   systemInfo  系统参数
 *   log_data   更新日志
 *
 */ 
 
const getCardTips = (obj) => {    
	let screenWidth = obj.system.screenWidth;
	let screenHeight = obj.system.screenHeight;
	  
	let content_top = (obj.system.screenHeight-357) / 2;
	let content_left = (obj.system.screenWidth - 330) / 2; 
	 
	
	// 绘制底层遮罩
	if (!mask) {
		mask = new plus.nativeObj.View('viewHotFixMask', {
			bottom: '0px',
			left: '0px',
			right: '0px',
			top: '0px',
		});
		mask.drawRect({
			color: 'rgba(0, 0, 0, 0.5)'
		});
		mask.show();
	}
	
	// 绘制弹窗背景
	if (!content_body) {
		content_body = new plus.nativeObj.View('content_body', {
			top: content_top + 'px',
			left: content_left + 'px',
			height: '357px',
			width: '330px',
			position: 'dock'
		})
		content_body.drawBitmap('/static/images/getCardTips_bg.png', {
			top: '0px',
			left: '0px',
			width: '100%',
			height: '100%'
		}, {
			top: 'auto',
			left: 'auto',
			width: '330px',
			height: '357px'
		});
		 
		 
	
		content_body.show();
	};
	

	// 绘制按钮
	if (!btn_confirm) {
		btn_confirm = new plus.nativeObj.View('btn_confirm', {
			top: (content_top+268) + 'px',
			left: (screenWidth-120)/2 + 'px',
			height: '30px',
			width: '120px',
			position: 'dock'
		})
		btn_confirm.drawRect({
			color: 'rgba(255,0,0,1)',
			radius: '15px'
		})
		btn_confirm.drawText('了解证书', {
			top: '0',
			left: '0',
			width: '120px',
			height: '30px'
		}, {
			align: 'center',
			size: '14px',
			color: '#fff'
		});
		btn_confirm.addEventListener("click", () => {
			uni.navigateTo({
				url:'/package_member/certificate/certificate?type=1' 		
			}) 
			setTimeout(()=>{
				Hide();	
			},300)
			
		}, false);
	
		btn_confirm.show();
	}
	
	// 绘制关闭按钮
	if (!btn_close) {
		btn_close = new plus.nativeObj.View('btn_close', {
			top: content_top + 350 + 'px',
			left: plus.os.name==="Android"?content_left+145+ 'px':content_left+148+ 'px',
			height: '30px',
			width: '30px',
			position: 'dock'
		})  
		btn_close.drawBitmap('/static/images/close_icon.png', {
			top: '0px',
			left: '0px',
			width: '100%',
			height: '100%'
		}, {
			top: 'auto',
			left: 'auto',
			height: '30px',
			width: '30px',
		}); 
			
		btn_close.show();
		btn_close.addEventListener("click", () => {
			Hide();
		}, false);
	}
	
	 
};
 
 
const Hide = () => {  
	if (mask) { 
		mask.hide();
		mask=null;
	}  
	if (content_body) {
		content_body.hide();
		content_body=null;
	}
	if (btn_confirm) { 
		btn_confirm.hide();
		btn_confirm=null;
	} 
	if (btn_close) {
		btn_close.hide();
		btn_close=null;
	} 
}
 

export {
	getCardTips,
	Hide 
}
